package com.todo.strategy.online.application.frontend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.strategy.online.application.frontend.service.UserStrategyAggService;
import com.todo.strategy.online.iface.UserStrategyFrontendIface;
import com.todo.strategy.online.iface.request.*;
import com.todo.strategy.online.iface.response.StrategyBaseVO;
import com.todo.strategy.online.iface.response.UserStrategyDetailVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/5/21 14:25
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/strategy")
@Tag(name = "用户攻略前台接口", description = "用户攻略前台接口")
public class UserStrategyFrontendController implements UserStrategyFrontendIface {

    @Resource
    private UserStrategyAggService userStrategyAggService;

    @Override
    @Operation(summary = "新增用户攻略")
    @PostMapping("/insertUserStrategy")
    public BizResponse<Boolean> insertUserStrategy(InsertUserStrategyParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return userStrategyAggService.insertUserStrategy(param);
    }

    @Override
    @Operation(summary = "更新用户攻略")
    @PostMapping("/updateUserStrategy")
    public BizResponse<Boolean> updateUserStrategy(UpdateUserStrategyParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return userStrategyAggService.updateUserStrategy(param);
    }

    @Override
    @Operation(summary = "删除用户攻略")
    @PostMapping("/removeUserStrategy")
    public BizResponse<Boolean> removeUserStrategy(RemoveUserStrategyParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return userStrategyAggService.removeUserStrategy(param);
    }

    @Override
    @Operation(summary = "根据用户id查询用户攻略列表")
    @PostMapping("/queryUserStrategyListByUserId")
    public BizPageResponse<StrategyBaseVO> queryUserStrategyListByUserId(QueryUserStrategyByUserIdParam param) {
        if (param == null) {
            return BizPageResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.success("查询失败，请刷新后重新操作");
        }
        return userStrategyAggService.queryUserStrategyListByUserId(param);
    }

    @Override
    @Operation(summary = "根据id查询用户攻略详情")
    @PostMapping("/queryUserStrategyById")
    public BizResponse<UserStrategyDetailVO> queryUserStrategyById(QueryUserStrategyByIdParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return userStrategyAggService.queryUserStrategyById(param);
    }
}
